package com.jifeng.sterilizer.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;
import java.util.Date;

import com.jifeng.sterilizer.valid.AddGroupValid;
import com.jifeng.sterilizer.valid.UpdateGroupValid;
import lombok.Data;

import javax.validation.constraints.*;

/**
 * 用户表
 * 
 * @author jifeng
 * @email 1593140625@qq.com
 * @date 2020-07-26 16:33:58
 */
@Data
@TableName("tbl_user")
public class UserEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * id
	 */
	@TableId
	@Null(message = "用户ID需要为空！",groups = {AddGroupValid.class})
	@NotNull(message = "用户ID不能为空！",groups = {UpdateGroupValid.class})
	private Long id;
	/**
	 * 最长不超过16位
	 */
	@NotBlank(message = "手机号不能为空！",groups = {AddGroupValid.class})
	@Pattern(regexp = "^1[0-9]{10}$",message = "手机号格式错误！",groups = {AddGroupValid.class,UpdateGroupValid.class})
	private String account;
	/**
	 * 固定6位
	 */
	@NotBlank(message = "密码不能为空！",groups = {AddGroupValid.class})
	@Pattern(regexp = "^\\d{6}$",message = "密码格式错误！",groups = {AddGroupValid.class,UpdateGroupValid.class})
	@Max(value = 6)
	@Min(value = 6)
	private String password;
	/**
	 * 0 超级管理|1 手机端管理|2 PC端管理员 |3 农场 |4 手机用户 
            超级管理员可以增删管理员/管理员管理农场 /用户属于农场
	 */
	private Integer type;
	/**
	 * 0 未审核 | 1 审核拒绝 |2 审核通过，除手机用户外，后台添加用户均默认审核通过
	 */
	private Integer status;
	/**
	 * 所属农场
	 */
	@NotNull(message = "农场不能为空！",groups = {AddGroupValid.class})
	private Long farmId;
	/**
	 * 备注
	 */
	private String memo;
	/**
	 * 1 有效 0无效
	 */
	private Integer enabled;
	/**
	 * 创建时间
	 */
	private Date createTime;
	/**
	 * 更新时间
	 */
	private Date updateTime;
	/**
	 * 身份证号
	 */
	@NotBlank(message = "身份证不能为空！",groups = {AddGroupValid.class})
	@Pattern(regexp = "^[1-9]\\d{7}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}$|^[1-9]\\d{5}[1-9]\\d{3}((0\\d)|(1[0-2]))(([0|1|2]\\d)|3[0-1])\\d{3}([0-9]|X)$",message = "身份证格式错误！",groups = {AddGroupValid.class,UpdateGroupValid.class})
	private String idcard;
	/**
	 * 名字
	 */
	@NotBlank(message = "名字不能为空！",groups = {AddGroupValid.class})
	private String name;

	@TableField(exist = false)
	@NotBlank(message = "验证码不能为空！",groups = {AddGroupValid.class})
	private String vcode;

	@TableField(exist = false)
	private String farmName;
}
